﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ExcelToOracle
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

            Stack<ToolStripItem> stack = new Stack<ToolStripItem>();

            foreach (ToolStripItem item in _ctlMenuStrip.Items)
            {
                stack.Push(item);
            }

            while (stack.Count > 0)
            {
                ToolStripMenuItem item = stack.Pop() as ToolStripMenuItem;
                if (item != null)
                {
                    if (item.Tag != null)
                    {
                        item.Click += new EventHandler(item_Click);
                    }
                    foreach (ToolStripItem child in item.DropDownItems)
                    {
                        stack.Push(child);
                    }
                }
            }
        }

        void item_Click(object sender, EventArgs e)
        {
            ToolStripMenuItem item = sender as ToolStripMenuItem;
            Form form = this.GetType().Assembly.CreateInstance(item.Tag.ToString()) as Form;
            if (form != null)
            {
                //form.ShowInTaskbar = false;
                //form.WindowState = FormWindowState.Maximized;
                form.ShowDialog();
            }
            else
            {
                MessageBox.Show("Coming soon!");
                //MessageBox.Show("打开失败:" + item.Tag.ToString());
            }
        }

        private void _ctlMenuItemExit_Click(object sender, EventArgs e)
        {
            Close();
        }
    }
}
